import timeit
def bubble(w):
    swapped = False
    for i in range(len(w),0,-1):
        swapped = False
        for j in range(0,i-1):
            if (w[j] > w[j+1]):
                temp = w[j]
                w[j] = w[j+1]
                w[j+1] = temp
                swapped = True
        if not swapped:
            return w

a = list(map(int, open("m1_sorted.txt").read().splitlines()))
b = list(map(int, open("m2_reverse.txt").read().splitlines()))
c = list(map(int, open("m3_shuffle.txt").read().splitlines()))
print("m1_sorted",str(int(timeit.timeit("bubble(a)", "from __main__ import a,bubble", number=1)*1000)),"milliseconds")
print("m2_reverse",str(int(timeit.timeit("bubble(b)", "from __main__ import b,bubble", number=1)*1000)),"milliseconds")
print("m3_shuffle",str(int(timeit.timeit("bubble(c)", "from __main__ import c,bubble", number=1)*1000)),"milliseconds")

# print(bubble(a))